package com.summer.freeMarker;

import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;

import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;

public class TestOne {

	public static void main(String[] args) throws IOException, TemplateException {
		Configuration config = new Configuration();
		config.setDirectoryForTemplateLoading(new File("ftl/"));
		Template template= config.getTemplate("b.ftl");
		Writer out = new StringWriter();
		HashMap<String,String> child = new HashMap<>();
		child.put("name","子节点");
		child.put("url", "www.baidu.com");
		HashMap<String,Object> map = new HashMap<>();
		map.put("name", "Summer");
		map.put("true", "ceshi");
		map.put("tt", "");
		map.put("summer-number","123");
		map.put("child",child);
		ArrayList<String> listValue = new ArrayList<>();
		listValue.add("one");
		listValue.add("two");
		listValue.add("there");
		map.put("listValue",listValue);
		template.process(map, out);
		
		System.out.println(out.toString());
	}

}
